{include file="common/blank" /}
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<title>编辑用户 - H-ui.admin v3.1</title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-member-add" enctype="multipart/form-data">
		<input type="hidden" id="id" name="id" value="{$data.id}">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>会员名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.user_name}" placeholder="" id="user_name" name="user_name">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.password}" placeholder="" id="password" name="password">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>头像：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<img src="{$data.user_logo}" alt="" width="50" height="50">
				<input class="file" type="file" name="file" id="file">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.phone}" placeholder="" id="phone" name="phone">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年龄：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$data.age}" placeholder="" id="age" name=age">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>邮箱：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" placeholder="@" name="email" id="email" value="{$data.email}">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>状态：</label>
			<div class="formControls col-xs-8 col-sm-9 skin-minimal">
				<div class="radio-box">
					<input type="radio" id="status-1" name="status" value="1"  {if condition="$data.status eq 1"}checked{/if}>
					<label for="status-1">已启用</label>
				</div>
				<div class="radio-box">
					<input type="radio" id="status-0" name="status" value="0" {if condition="$data.status eq 0"}checked{/if}>
					<label for="status-0">已禁用</label>
				</div>
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" onclick="check()" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
{include file="common/footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/static/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
    $(function(){
        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });

        $("#form-member-add").validate({
            rules:{
                user_name:{
                    required:true,
                    minlength:2,
                    maxlength:16
                },
                status:{
                    required:true,
                },
                email:{
                    required:true,
                    email:true,
                },
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
            }
        });
    });

    function check() {
        var id = $.trim($('#id').val());
        var user_name = $.trim($('#user_name').val());
        var email = $.trim($('#email').val());
        var age = $.trim($('#age').val());
        var phone = $.trim($('#phone').val());
        var password = $.trim($('#password').val());
        var status = $('input[name=status]:checked').val();
        if(user_name=="" || email=="" || phone=="" || password==""){
            layer.msg('请填写信息',{icon:2,time:2000});
            return false;
        }
        var formData = new FormData();
        formData.append("file", $("#file").get(0).files[0]);
        formData.append("id", id);
        formData.append("user_name", user_name);
        formData.append("age", age);
        formData.append("email", email);
        formData.append("phone", phone);
        formData.append("password", password);
        formData.append("status", status);
        $.ajax({
            url:"{:url('admin/user/editUser')}",
            type:'POST',
            data:formData,
            cache: false,
            contentType: false,    //不可缺
            processData: false,    //不可缺
            success:function(data){
                var msg=data.msg;
                if(data.code == 1){
                    layer.msg(msg, {
                        icon: 1,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function(){
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.$('.btn-primary').click();
                        window.parent.location.reload();
                        parent.layer.close(index);
                    });
                }else{
                    layer.msg(msg,{icon:2,time:2000});
                }
            }
        });

    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>